<?php
/**
 * Geneone: Content Management Framework
 * View Drafts
 *
 * http://geneone.neondragon.net/
 *
 * @package Geneone
 * @author Khlo
 * @version 1.0
 * @copyright 2004-2006 Geneone Development Team
 */
 
require_once 'Gene/Object.php';
require_once 'Gene/Object/Draft.php';
 
class Gene_Special_Drafts {
	/**
	 * Default Action
	 */
	function main() {
		$tpl =& Gene::getTemplate();
		$db =& Gene::getDatabase();
		$user =& Gene::getUser();
		
		// Delete?
		$delete = Gene_Request::getInteger("delete", GENE_REQUEST_POST);
		if ($delete) {
			Gene_Object_Draft::remove($delete);
			$tpl->assign ("deleted", $delete);
		}
		
		$drafts = Gene_Object_Draft::listDrafts($user);
		foreach ($drafts as $i => $j) {
			$drafts[$i]['parent'] = array(
				"object_id" => $j['parent_id'],
				"title" => $j['parenttitle'],
				"alias" => $j['parentalias'],
			);
		}
		
		$tpl->assign ("drafts", $drafts);
		
		$tpl->assign ("finalbody", $tpl->fetch("special/drafts"));
	}
}
?>